﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Cms.Domain;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cms.Tests.Unit.Domain
{
    [TestClass]
    public class CategoryTests
    {
        [TestMethod]
        public void GetAllIds_CategoryHasSubCategories_AllIDsAreReturned()
        {
            Category animals = new Category { ID = 1 };
            Category mammals = new Category { ID = 2, Parent = animals };
            Category insects = new Category { ID = 3, Parent = animals };
            Category dogs = new Category { ID = 4, Parent = mammals };
            Category cats = new Category { ID = 5, Parent = mammals };
            Category spiders = new Category { ID = 6, Parent = insects };
            animals.SubCategories.Add(mammals);
            animals.SubCategories.Add(insects);
            mammals.SubCategories.Add(dogs);
            mammals.SubCategories.Add(cats);
            insects.SubCategories.Add(spiders);
            Assert.AreEqual("1, 2, 4, 5, 3, 6", string.Join(", ", animals.GetAllIDs()));
            Assert.AreEqual("4", string.Join(", ", dogs.GetAllIDs()));
            Assert.AreEqual("3, 6", string.Join(", ", insects.GetAllIDs()));
        }
    }
}
